//
//  UIImageView+TW.m
//  TWHomework-WeChat
//
//  Created by wzb on 2019/11/13.
//  Copyright © 2019 WZB. All rights reserved.
//

#import "UIImageView+TW.h"
#import "TWImageCacheManager.h"

@implementation UIImageView (TW)

- (void)tw_setImage:(NSString *)url
{
    if (!url || [url isKindOfClass:NSNull.class] || url.length == 0) return;
    [self tw_setImage:url placeholderImageName:nil];
}
- (void)tw_setImage:(NSString *)url placeholderImageName:(NSString * _Nullable )imageName
{
    self.image = [UIImage imageNamed:imageName];
    [[TWImageCacheManager sharedManager] imageFromURL:url success:^(UIImage * _Nonnull image) {
        if (self.image != image) {
            self.image = image;
        }
    }];
}

@end
